package bs

import net.liftweb._
import http._
import util._
import Helpers._
import scala.xml.NodeSeq


trait Navbar extends LiftComponent {
  val _brand: Link
  val _items: Seq[LiftComponent with NavItem]

  override val template = Templates("templates-hidden" :: "bs" :: "_navbar" :: Nil).get
  override def transformer = ".brand *" #> _brand.text & ".brand [href]" #> _brand.url &
    ".nav" #> {
      "li" #> _items.map { item =>
        "li *" #> item.render andThen item.nav_item_transfer
      }
    }

  val style: String
}

trait NavItem {self: LiftComponent =>
  val nav_item_transfer: NodeSeq => NodeSeq = identity

}

case class FixedTopNavbar(brand: Link, items: LiftComponent with NavItem*) extends Navbar {
  override val _brand = brand
  override val _items = items
  override val style = "fixed-top"
}

// ToDo: other styles
